<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('商编查询')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>导出状态：</label>
                                <select name="status">
                                    <option value="">请选择</option>
                                    <option value="0">生成成功</option>
                                    <option value="1">生成失败</option>
                                    <option value="2">正在生成</option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "ReportMerchant";
        var downFlag = [[${@permission.hasPermi('ReportMerchant:downFile')}]];
        $(function() {
            var options = {
                url: prefix + "/getJobTaskList",
                clickToSelect: true,
                modalName: "后台队列",
                columns: [
                {
                    field: 'ID',
                    title: '任务编号'
                },
                {
                    field: 'OPERATOR_TYPE',
                    title: '操作类型',
                    formatter: function(value, row, index) {
                        if (value == '3'){
                            return '商编任务';
                        }
                        return '';
                    }
                },
                {
                    field: 'OPERATOR_CONTENT',
                    title: '操作内容'
                },
                {
                    field: 'CREATE_BY',
                    title: '添加人'
                },
                {
                    field: 'CREATE_TIME',
                    title: '添加时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.FILE_NAME != 'operation') {
                            actions.push('<a class="btn btn-warning btn-xs ' + downFlag + '" href="javascript:void(0)" onclick="downloadFile(\'' + row.ID + '\')"><i class="fa fa-search"></i>下载文件</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function downloadFile(id){
          $.modal.confirm("确定下载吗？", function() {
            window.location.href = prefix + "/downloadFile?id=" + id;
          });
        }
    </script>
</body>
</html>